##
## Test functions

package Purl::tests;

sub sexTest {
    my ( $me, $f, $m, $n ) = @_;
    my ($x);
    if ( $main::objects[$me]{"sex"} =~ /^female$/i ) {
        $x = $f;
    }
    elsif ( $main::objects[$me]{"sex"} =~ /^male$/i ) {
        $x = $m;
    }
    else {
        $x = $n;
    }
    return $x;
}

sub isWizard {
    my ($me) = @_;
    return 1
        if ( ( $me == 1 )
        || ( $main::objects[$me]{"flags"} & $main::flags{"wizard"}{"value"} )
        );    # Object #1 is always a wizard
}

sub isBuilder {
    my ($me) = @_;
    return (
        ( $main::objects[$me]{"flags"} & $main::flags{"builder"}{"value"} )
            || (
            $main::objects[$me]{"flags"} & $main::flags{"wizard"}{"value"} )
    ) ? 1 : 0;
}

sub canBuild {
    my $me = shift;
    return 1 if ( isBuilder($me) || isWizard($me) );
    return 0;
}

sub canIdle {
    my $id = shift;
    return 1 if ( isWizard($id) );
    # return 1 if WHATEVER-THE-IDLE-FLAG-WIll-BE
    return 0;
}

sub controls {
    my ( $me, $dbref ) = @_;
    return ( ( $main::objects[$dbref]{"owner"} == $me )
            || &Purl::tests::isWizard($me) ) ? 1 : 0;
}

sub alphaNumeric {
    $_ = shift;
    return 1 if /\w/;
    return 0;
}

sub lockEvalWord {
    my ( $me, $word ) = @_;

    $word =~ s/^\s+//g;
    $word =~ s/\s+$//g;

    return 1 if ( $word eq "" );
    return 1 if ( ( "#" . $me ) eq $word );
    return 1 if ( &findContents( $me, $word ) != $none );
    return 0;
}

1;
